﻿Imports Logica

Partial Class MasterPage
    Inherits System.Web.UI.MasterPage
    Private m_mostrarMenu As Boolean

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' Mostrar el menú
        Session.Add("mostrarMenu", True)

        ' Comprueba si se ha iniciado sesión
        If Session.Item("identificacion") Is Nothing Then
            Response.Redirect("Login.aspx")
        End If

        ' Notificar CV
        Dim ID As String
        Dim retroalimentacion As String
        ID = Session.Item("identificacion")

        If Not IsPostBack() Then
            If Not Request.Url.AbsolutePath = "/Web/ActualizarCurriculoVitae.aspx" Then
                If Gestor.notificarCV(ID) Then
                    retroalimentacion = "Debe actualizar su curriculo."
                    Session("mostrarMenu") = False
                    Response.Redirect("ActualizarCurriculoVitae.aspx?id=" & ID & "&t=" & retroalimentacion)
                End If
            Else
                If Gestor.notificarCV(ID) Then
                    Session("mostrarMenu") = False
                End If
            End If
        End If
    End Sub

    Public Function mostrarMenu() As String
        Dim buffer As String = ""

        If Session("mostrarMenu") Then
            buffer = "<ul>" & vbCrLf
            buffer &= "  <li><a href='ConsultarUsuario.aspx'>Perfil</a></li>" & vbCrLf
            buffer &= "  <li>Usuarios" & vbCrLf
            buffer &= "      <ul>" & vbCrLf
            buffer &= "          <li><a href='BuscarUsuario.aspx'>Buscar</a></li>" & vbCrLf
            buffer &= "          <li><a href='RegistrarUsuario.aspx'>Registrar</a></li>" & vbCrLf
            buffer &= "      </ul>" & vbCrLf
            buffer &= "  </li>" & vbCrLf
            buffer &= "  <li><a href='MostrarSubordinados.aspx'>Evaluaciones</a></li>" & vbCrLf
            buffer &= "  <li><a href='AplicarPlanilla.aspx'>Aplicar Planilla</a></li>" & vbCrLf
            buffer &= "  <li><a href='DescargarPuesto.aspx'>Manuel de Puestos</a></li>" & vbCrLf
            buffer &= "</ul>"
        End If

        Return buffer
    End Function
End Class

